using System.Threading;
using Godot;
using System;
using System.Collections.Generic;

public class SteamCrusherView : StoreView
{
    public TextureProgress steam;
    public Label steamLabel;
    public List<Slot> Slots = new List<Slot>();
    public override void _Ready()
    {
        base._Ready();
        steam = GetNode<TextureProgress>("steam_progress");
        steamLabel = GetNode<Label>("steam_progress/Label");
        Slots.Add(GetNode<Slot>("Input_0"));
       // Slots.Add(GetNode<Slot>("Input_1"));
        Slots.Add(GetNode<Slot>("Output_0"));
       // Slots.Add(GetNode<Slot>("Output_1"));
        for (int i = 0; i < Slots.Count; i++)
        {
            Slots[i].index = i;
            Slots[i].OnClickEvent = ClickSlot;
            Slots[i].OnShiftClickEvent = ShiftClickSlot;
            Slots[i].HoldIn = BlockHoldIn;
            Slots[i].HoldOver = HoldOver;
        }
    }
    public override void Updata(Player player)
    {
        base.Updata(player);
        if (player!=null&&block != null)
        {
            SteamCrusherBlockEntity scbe = (SteamCrusherBlockEntity)block.blockEntity;
            for (int i = 0; i < Slots.Count; i++)
            {
                Slots[i].SetItemStack(scbe.store.GetItemStack(Slots[i].index));
            }
            steam.Value = (scbe.steam.GetPercentage() * 100f);
            steamLabel.Text = scbe.steam.ToString("ml");
        }
    }
}
